package com.github.iot.dao;

import com.github.iot.dao.greendao.ButtonDao;
import com.github.iot.dao.greendao.DoorCommandDao;
import com.github.iot.dao.greendao.DoorDao;
import com.github.iot.dao.greendao.LightDao;
import com.github.iot.dao.greendao.NetPatternDao;
import com.github.iot.dao.greendao.NetServerDao;
import com.github.iot.dao.greendao.ShowcaseDao;
import com.github.iot.dao.greendao.ShowroomDao;
import com.github.iot.dao.greendao.SystemSettingDao;
import com.github.iot.dao.greendao.UserDao;
import com.github.iot.dao.greendao.UserTokenDao;
import com.github.iot.entity.Button;
import com.github.iot.entity.Door;
import com.github.iot.entity.DoorCommand;
import com.github.iot.entity.Light;
import com.github.iot.entity.NetPattern;
import com.github.iot.entity.NetServer;
import com.github.iot.entity.Showcase;
import com.github.iot.entity.Showroom;
import com.github.iot.entity.SystemSetting;
import com.github.iot.entity.User;
import com.github.iot.entity.UserToken;

/**
 * 存放DaoUtils
 *
 * @Author: 梁声洪
 * @Date: 2019/12/7 13:53
 * @Version: v1.0.0
 */
public class DaoUtilsStore {

    private volatile static DaoUtilsStore instance = new DaoUtilsStore();

    private CommonDaoUtils<User> userDaoUtils;
    private CommonDaoUtils<UserToken> userTokenDaoUtils;
    private CommonDaoUtils<Showroom> showroomDaoUtils;
    private CommonDaoUtils<Showcase> showcaseDaoUtils;
    private CommonDaoUtils<NetPattern> netPatternDaoUtils;
    private CommonDaoUtils<NetServer> netServerDaoUtils;
    private CommonDaoUtils<Door> doorDaoUtils;
    private CommonDaoUtils<Light> lightDaoUtils;

    private CommonDaoUtils<Button> buttonDaoUtils;
    private CommonDaoUtils<DoorCommand> doorCommandDaoUtils;

    private CommonDaoUtils<SystemSetting> systemSettingDaoUtils;

    public static DaoUtilsStore getInstance() {
        return instance;
    }

    private DaoUtilsStore() {
        DaoManager mManager = DaoManager.getInstance();

        UserDao userDao = mManager.getDaoSession().getUserDao();
        userDaoUtils = new CommonDaoUtils(User.class, userDao);

        UserTokenDao userTokenDao = mManager.getDaoSession().getUserTokenDao();
        userTokenDaoUtils = new CommonDaoUtils(UserToken.class, userTokenDao);

        ShowroomDao showroomDao = mManager.getDaoSession().getShowroomDao();
        showroomDaoUtils = new CommonDaoUtils(Showroom.class, showroomDao);

        ShowcaseDao showcaseDao = mManager.getDaoSession().getShowcaseDao();
        showcaseDaoUtils = new CommonDaoUtils(Showcase.class, showcaseDao);

        NetPatternDao netPatternDao = mManager.getDaoSession().getNetPatternDao();
        netPatternDaoUtils = new CommonDaoUtils(NetPattern.class, netPatternDao);

        NetServerDao netServerDao = mManager.getDaoSession().getNetServerDao();
        netServerDaoUtils = new CommonDaoUtils(NetServer.class, netServerDao);

        DoorDao doorDao = mManager.getDaoSession().getDoorDao();
        doorDaoUtils = new CommonDaoUtils(Door.class, doorDao);

        LightDao lightDao = mManager.getDaoSession().getLightDao();
        lightDaoUtils = new CommonDaoUtils(Light.class, lightDao);

        DoorCommandDao doorCommandDao = mManager.getDaoSession().getDoorCommandDao();
        doorCommandDaoUtils = new CommonDaoUtils(DoorCommand.class, doorCommandDao);

        ButtonDao buttonDao = mManager.getDaoSession().getButtonDao();
        buttonDaoUtils = new CommonDaoUtils(Button.class, buttonDao);

        SystemSettingDao settingDao = mManager.getDaoSession().getSystemSettingDao();
        systemSettingDaoUtils = new CommonDaoUtils(SystemSetting.class, settingDao);
    }

    public CommonDaoUtils<User> getUserDaoUtils() {
        return userDaoUtils;
    }

    public CommonDaoUtils<UserToken> getUserTokenDaoUtils() {
        return userTokenDaoUtils;
    }

    public CommonDaoUtils<Showroom> getShowroomDaoUtils() {
        return showroomDaoUtils;
    }

    public CommonDaoUtils<Showcase> getShowcaseDaoUtils() {
        return showcaseDaoUtils;
    }

    public CommonDaoUtils<NetPattern> getNetPatternDaoUtils() {
        return netPatternDaoUtils;
    }

    public CommonDaoUtils<NetServer> getNetServerDaoUtils() {
        return netServerDaoUtils;
    }

    public CommonDaoUtils<Door> getDoorDaoUtils() {
        return doorDaoUtils;
    }

    public CommonDaoUtils<Light> getLightDaoUtils() {
        return lightDaoUtils;
    }

    public CommonDaoUtils<Button> getButtonDaoUtils() {
        return buttonDaoUtils;
    }

    public CommonDaoUtils<DoorCommand> getDoorCommandDaoUtils() {
        return doorCommandDaoUtils;
    }

    public CommonDaoUtils<SystemSetting> getSystemSettingDaoUtils() {
        return systemSettingDaoUtils;
    }

}